Skip to content

Refuse to quote a value the driver cannot quote - #89

Open
tyrsson wants to merge 1 commit into
rfc/256-statement-factoryfrom
rfc/256-platform-value-quoting
Open

tyrsson wants to merge 1 commit into
rfc/256-statement-factoryfrom
rfc/256-platform-value-quoting

Conversation

@tyrsson

@tyrsson tyrsson commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Companion to php-db/phpdb#259, which stops AbstractPlatform declaring quoteValue() so that each platform states its own value-quoting policy.

  • AdapterPlatform::quoteValue() asks the driver and refuses when the driver cannot answer, instead of falling back to AbstractPlatform::quoteValue().

Why: the fallback escaped the value without consulting the driver, which is the path taken while the connection is not open. An untrusted value silently received dialect-agnostic backslash escaping rather than a refusal, and for MySQL that form is not the one the driver produces.

  • The DDL unit tests build their platform from a live PDO handle, because a COMMENT column option is a value and now needs one.
  • The three unit tests that asserted the fallback now assert the refusal.

Stacked on #88, which is where getStatementFactory() arrives.

Tracked in php-db/phpdb#260.

quoteValue() fell back to AbstractPlatform::quoteValue(), which escaped the value without
consulting the driver. That is the path taken while the connection is not open, so an untrusted
value silently received dialect-agnostic backslash escaping instead of a refusal.

php-db/phpdb removes that inherited method in phpdb#259, so the fallback goes with it and the
platform states its own policy: ask the driver, and refuse when it cannot answer.

The DDL tests build their platform from a live PDO handle, because a COMMENT option is a value and
now needs one. The three unit tests that asserted the fallback now assert the refusal.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant